﻿using AutoMapper;
using FileManager_Server.DataLayer.Castle_Model;
using FileManager_Server.ServiceModel.DataTransfer_Model;

namespace FileManager_Server.BusinessLogic.AutoMapper_Setting
{
    public class AutoMapperInitialize
    {
         public static void InitializeAutoMapper()
         {
             Mapper.CreateMap<UserDbModel, UserLoginResult>()
              .ForMember(us => us.CellPhone, m => m.MapFrom(x => x.CELLPHONE))
              .ForMember(us => us.CompanyId, m => m.MapFrom(x => x.COMPANYID))
              .ForMember(us => us.DiskLarge, m => m.MapFrom(x => x.DISKLARGE))
              .ForMember(us => us.Duty, m => m.MapFrom(x => x.DUTY))
              .ForMember(us => us.Email, m => m.MapFrom(x => x.EMAIL))
              .ForMember(us => us.LoginId, m => m.MapFrom(x => x.LOGINID))
              .ForMember(us => us.OrderNumber, m => m.MapFrom(x => x.ORDERNUMBER))
              .ForMember(us => us.PeopleName, m => m.MapFrom(x => x.NAME))
              .ForMember(us => us.Sex, m => m.MapFrom(x => x.SEX))
              .ForMember(us => us.Sid, m => m.MapFrom(x => x.SID))
              .ForMember(us => us.TelePhone, m => m.MapFrom(x => x.TELEPHONE))
              .ForMember(us => us.UserId, m => m.MapFrom(x => x.USERID));

             Mapper.CreateMap<FileDbModel, FileResult>()
              .ForMember(us => us.CreateId, m => m.MapFrom(x => x.CREATORID))
              .ForMember(us => us.CreateName, m => m.MapFrom(x => x.CREATOR))
              .ForMember(us => us.CreateTime, m => m.MapFrom(x => x.CREATETIME))
              .ForMember(us => us.FileMark, m => m.MapFrom(x => x.FILEMARK))
              .ForMember(us => us.FileName, m => m.MapFrom(x => x.FILENAME))
              .ForMember(us => us.FilePath, m => m.MapFrom(x => x.FILEPATH))
              .ForMember(us => us.FileSid, m => m.MapFrom(x => x.FILESID))
              .ForMember(us => us.FileSize, m => m.MapFrom(x => x.FILESIZE))
              .ForMember(us => us.IsFile, m => m.MapFrom(x => x.ISFILE))
              .ForMember(us => us.IsShare, m => m.MapFrom(x => x.ISSHARE))
              .ForMember(us => us.OwnerId, m => m.MapFrom(x => x.OWNERID))
              .ForMember(us => us.ParentId, m => m.MapFrom(x => x.PARENTID))
              .ForMember(us => us.UpdateId, m => m.MapFrom(x => x.UPDATERID))
              .ForMember(us => us.UpdateName, m => m.MapFrom(x => x.UPDATER))
              .ForMember(us => us.UpdateTime, m => m.MapFrom(x => x.UPDATETIME));

             Mapper.CreateMap<FileDbModel, FolderResult>()
                 .ForMember(us => us.CreateId, m => m.MapFrom(x => x.CREATORID))
                 .ForMember(us => us.CreateName, m => m.MapFrom(x => x.CREATOR))
                 .ForMember(us => us.CreateTime, m => m.MapFrom(x => x.CREATETIME))
                 .ForMember(us => us.FileName, m => m.MapFrom(x => x.FILENAME))
                 .ForMember(us => us.FilePath, m => m.MapFrom(x => x.FILEPATH))
                 .ForMember(us => us.FileSid, m => m.MapFrom(x => x.FILESID))
                 .ForMember(us => us.IsFile, m => m.MapFrom(x => x.ISFILE))
                 .ForMember(us => us.IsShare, m => m.MapFrom(x => x.ISSHARE))
                 .ForMember(us => us.OwnerId, m => m.MapFrom(x => x.OWNERID))
                 .ForMember(us => us.ParentId, m => m.MapFrom(x => x.PARENTID))
                 .ForMember(us => us.UpdateId, m => m.MapFrom(x => x.UPDATERID))
                 .ForMember(us => us.UpdateName, m => m.MapFrom(x => x.UPDATER))
                 .ForMember(us => us.UpdateTime, m => m.MapFrom(x => x.UPDATETIME));

             Mapper.CreateMap<Company, CompanyResult>()
             .ForMember(us => us.Id, m => m.MapFrom(x => x.ID))
             .ForMember(us => us.Pid, m => m.MapFrom(x => x.PID))
             .ForMember(us => us.CompanyName, m => m.MapFrom(x => x.SHORTNAME))
             .ForMember(us => us.ShortName, m => m.MapFrom(x => x.SHORTNAME))
             .ForMember(us => us.Sncode, m => m.MapFrom(x => x.SNCODE));

             //FileRoleDbModel
             Mapper.CreateMap<FileRoleDbModel, FolderRoleResult>()
                 .ForMember(us => us.IsCreate, m => m.MapFrom(x => x.ISCREATE))
                 .ForMember(us => us.IsDelete, m => m.MapFrom(x => x.ISDELETE))
                 .ForMember(us => us.IsJustMe, m => m.MapFrom(x => x.ISOWNER))
                 .ForMember(us => us.IsRead, m => m.MapFrom(x => x.ISREAD))
                 .ForMember(us => us.IsUpdate, m => m.MapFrom(x => x.ISUPDATE))
                 .ForMember(us => us.FileId, m => m.MapFrom(x => x.FILESID));

             Mapper.CreateMap<FileRoleDbModel, FileRoleAddResult>()
                 .ForMember(us => us.IsCreate, m => m.MapFrom(x => x.ISCREATE))
                 .ForMember(us => us.IsDelete, m => m.MapFrom(x => x.ISDELETE))
                 .ForMember(us => us.IsJustMe, m => m.MapFrom(x => x.ISOWNER))
                 .ForMember(us => us.IsRead, m => m.MapFrom(x => x.ISREAD))
                 .ForMember(us => us.IsUpdate, m => m.MapFrom(x => x.ISUPDATE))
                 .ForMember(us => us.RoleSid, m => m.MapFrom(x => x.ROLESID))
                 .ForMember(us => us.RoleType, m => m.MapFrom(x => x.ROLETYPE))
                 .ForMember(us => us.FileSid, m => m.MapFrom(x => x.FILESID))
                 .ForMember(us => us.RelationId, m => m.MapFrom(x => x.RELATIONID))
                 .ForMember(us => us.IsInherit, m => m.MapFrom(x => x.ISINHERIT))
                 .ForMember(us => us.InheritFileSId, m => m.MapFrom(x => x.INHERITFILESID))
                 .ForMember(us => us.SetUserId, m => m.MapFrom(x => x.SETUSERID))
                 .ForMember(us => us.SetUserName, m => m.MapFrom(x => x.SETUSERNAME))
                 .ForMember(us => us.FlagSid, m => m.MapFrom(x => x.FLAGSID));

             Mapper.CreateMap<FileRoleAddResult, FileRoleDbModel>()
                 .ForMember(us => us.ROLESID, m => m.MapFrom(x => x.RoleSid))
                 .ForMember(us => us.ROLETYPE, m => m.MapFrom(x => x.RoleType))
                 .ForMember(us => us.FILESID, m => m.MapFrom(x => x.FileSid))
                 .ForMember(us => us.RELATIONID, m => m.MapFrom(x => x.RelationId))
                 .ForMember(us => us.ISREAD, m => m.MapFrom(x => x.IsRead))
                 .ForMember(us => us.ISCREATE, m => m.MapFrom(x => x.IsCreate))
                 .ForMember(us => us.ISDELETE, m => m.MapFrom(x => x.IsDelete))
                 .ForMember(us => us.ISUPDATE, m => m.MapFrom(x => x.IsUpdate))
                 .ForMember(us => us.ISINHERIT, m => m.MapFrom(x => false))
                 .ForMember(us => us.INHERITFILESID, m => m.MapFrom(x => ""))
                 .ForMember(us => us.FLAGSID, m => m.MapFrom(x => x.FlagSid))
                 .ForMember(us => us.ISOWNER, m => m.MapFrom(x => x.IsJustMe))
                 .ForMember(us => us.ISALLOWALLOCATE, m => m.MapFrom(x => true))
                 .ForMember(us => us.SETUSERID, m => m.MapFrom(x => x.SetUserId))
                 .ForMember(us => us.SETUSERNAME, m => m.MapFrom(x => x.SetUserName));

             Mapper.CreateMap<CompanyGroup, CompanyGroupResult>()
                 .ForMember(us => us.Glevel, m => m.MapFrom(x => x.GLEVEL))
                 .ForMember(us => us.GroupId, m => m.MapFrom(x => x.GROUPID))
                 .ForMember(us => us.Name, m => m.MapFrom(x => x.NAME))
                 .ForMember(us => us.Ordernumber, m => m.MapFrom(x => x.ORDERNUMBER))
                 .ForMember(us => us.Pid, m => m.MapFrom(x => x.PID))
                 .ForMember(us => us.Sid, m => m.MapFrom(x => x.SID))
                 .ForMember(us => us.Spid, m => m.MapFrom(x => x.SPID));

             Mapper.CreateMap<UserGroup, UserGroupResult>()
                 .ForMember(us => us.Glevel, m => m.MapFrom(x => x.GLEVEL))
                 .ForMember(us => us.Id, m => m.MapFrom(x => x.ID))
                 .ForMember(us => us.Name, m => m.MapFrom(x => x.NAME))
                 .ForMember(us => us.Ordernumber, m => m.MapFrom(x => x.ORDERNUMBER))
                 .ForMember(us => us.Pid, m => m.MapFrom(x => x.PID))
                 .ForMember(us => us.Sid, m => m.MapFrom(x => x.SID))
                 .ForMember(us => us.Spid, m => m.MapFrom(x => x.SPID));

             Mapper.CreateMap<FileRoleDbModel, NewFileRoleResult>()
                 .ForMember(us => us.FlagId, m => m.MapFrom(x => x.FLAGSID))
                 .ForMember(us => us.RelationId, m => m.MapFrom(x => x.RELATIONID))
                 .ForMember(us => us.RoleId, m => m.MapFrom(x => x.ROLESID));

             Mapper.CreateMap<FileLogDbModel, FileLogResult>()
                 .ForMember(us => us.Log, m => m.MapFrom(x => x.LOG))
                 .ForMember(us => us.LogSid, m => m.MapFrom(x => x.LOGSID))
                 .ForMember(us => us.LogTime, m => m.MapFrom(x => x.LOGTIME))
                 .ForMember(us => us.LogType, m => m.MapFrom(x => x.LOGTYPE))
                 .ForMember(us => us.ObjectId, m => m.MapFrom(x => x.OBJECTID))
                 .ForMember(us => us.TarGetName, m => m.MapFrom(x => x.TARGETNAME))
                 .ForMember(us => us.UserId, m => m.MapFrom(x => x.USERID))
                 .ForMember(us => us.UserName, m => m.MapFrom(x => x.USERNAME));

             Mapper.CreateMap<FileDepartsizeDbModel, DepartmentSizeResult>()
                 .ForMember(us => us.DepartmentSizeSid, m => m.MapFrom(x => x.DEPARTSIZESID))
                 .ForMember(us => us.DepartmentSid, m => m.MapFrom(x => x.DEPARTID))
                 .ForMember(us => us.DepartmentSizeMB, m => m.MapFrom(x => x.FILESIZE));
         }
    }
}